<template>
  <div class="news-list">
    <van-card
      v-for="item in newsList"
      :key="item.id"
      :title="item.title"
      :thumb="item.img_url"
      @click.prevent="goDetail(item.id)"
    >
      <template #price>
        {{item.add_time}}
      </template>
      <template #num>
        点击{{item.click}}次
      </template>
    </van-card>
  </div>
</template>
<script>
export default {
  data: () => ({
    newsList: []
  }),
  created() {
    this.getNewsList()
  },
  methods: {
    async getNewsList() {
      const res = await this.$http.getNewsList()
      this.newsList = res.data.message
    },
    goDetail(id) {
      this.$router.push('/home/newsinfo/' + id)
    }
  }
}
</script>
<style lang="scss">
.news-list {
  font-size: 12px;
  .van-card__thumb {
    height: 55px;
  }
  .van-card__content {
    min-height: 55px;
  }
  .van-card__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
  }
  .van-card__price {
    color: red;
  }
}
</style>
